import { defineStore } from 'pinia'
import setting from '@/config/setting'
import { SETTINGS_KEY } from '@/utils/enums/cacheEnums'
import cache from '@/utils/cache'
export const useSettingStore = defineStore('setting', {
    state: () => {
        const state = {
            ...setting
        }
        return state    
    },
    actions: {
        // 设置配置 
        setSetting(data: Record<string, any>) {
            const { key, value } = data
            if (this.hasOwnProperty(key)) {
                (this as any)[key] = value
            }
            const settings : any = Object.assign({}, this.$state)
            cache.set(SETTINGS_KEY, settings)
        }
    }
})